<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/9/21
 * Time: 20:03
 */

namespace App\Exceptions;

use Exception;

/**
 * 自定义接口返回响应类
 * Class ResposeException
 * @package App\Exceptions
 */
class ResponseException extends Exception
{

	protected $data = [];
	//定义一个构造方法接收参数
	public function __construct($code = '500',$msg = 'error',$data = []){

		$this->data = $data;
	    parent::__construct($msg,$code);
	}

	public function render()
	{
		$content = [
			'msg'=>$this->message,
			'code'=>$this->code,
			'data'=>$this->data,
			'timestamps'=>time(),
		];

		return response($content,200);
	}
}